package com.insuremonitor.system.service.impl;

import com.insuremonitor.common.core.domain.AjaxResult;
import com.insuremonitor.common.utils.DateUtils;
import com.insuremonitor.system.domain.FrontInsureConfigSafeguard;
import com.insuremonitor.system.mapper.FrontInsureConfigSafeguardMapper;
import com.insuremonitor.system.service.IFrontInsureConfigSafeguardService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 保险信息保障范围Service业务层处理
 * 
 * @author ruoyi
 * @date 2023-11-21
 */
@Service
public class FrontInsureConfigSafeguardServiceImpl implements IFrontInsureConfigSafeguardService 
{
    @Autowired
    private FrontInsureConfigSafeguardMapper frontInsureConfigSafeguardMapper;

    /**
     * 查询保险信息保障范围
     * 
     * @param safeguardId 保险信息保障范围主键
     * @return 保险信息保障范围
     */
    @Override
    public FrontInsureConfigSafeguard selectFrontInsureConfigSafeguardBySafeguardId(Long safeguardId)
    {
        return frontInsureConfigSafeguardMapper.selectFrontInsureConfigSafeguardBySafeguardId(safeguardId);
    }

    /**
     * 查询保险信息保障范围列表
     * 
     * @param frontInsureConfigSafeguard 保险信息保障范围
     * @return 保险信息保障范围
     */
    @Override
    public List<FrontInsureConfigSafeguard> selectFrontInsureConfigSafeguardList(FrontInsureConfigSafeguard frontInsureConfigSafeguard)
    {
        frontInsureConfigSafeguard.setStatus("1");
        return frontInsureConfigSafeguardMapper.selectFrontInsureConfigSafeguardList(frontInsureConfigSafeguard);
    }

    /**
     * 新增保险信息保障范围
     * 
     * @param frontInsureConfigSafeguard 保险信息保障范围
     * @return 结果
     */
    @Override
    public AjaxResult insertFrontInsureConfigSafeguard(FrontInsureConfigSafeguard frontInsureConfigSafeguard)
    {
        frontInsureConfigSafeguard.setCreateTime(DateUtils.getNowDate());
        int i =  frontInsureConfigSafeguardMapper.insertFrontInsureConfigSafeguard(frontInsureConfigSafeguard);
        if(i>0){
            return AjaxResult.success("操作成功",frontInsureConfigSafeguard.getSafeguardId());
        }else {
            return AjaxResult.error("操作失败");
        }
    }

    /**
     * 修改保险信息保障范围
     * 
     * @param frontInsureConfigSafeguard 保险信息保障范围
     * @return 结果
     */
    @Override
    public int updateFrontInsureConfigSafeguard(FrontInsureConfigSafeguard frontInsureConfigSafeguard)
    {
        frontInsureConfigSafeguard.setUpdateTime(DateUtils.getNowDate());
        return frontInsureConfigSafeguardMapper.updateFrontInsureConfigSafeguard(frontInsureConfigSafeguard);
    }

    /**
     * 批量删除保险信息保障范围
     * 
     * @param safeguardIds 需要删除的保险信息保障范围主键
     * @return 结果
     */
    @Override
    public int deleteFrontInsureConfigSafeguardBySafeguardIds(Long[] safeguardIds)
    {
        return frontInsureConfigSafeguardMapper.deleteFrontInsureConfigSafeguardBySafeguardIds(safeguardIds);
    }

    /**
     * 删除保险信息保障范围信息
     * 
     * @param safeguardId 保险信息保障范围主键
     * @return 结果
     */
    @Override
    public int deleteFrontInsureConfigSafeguardBySafeguardId(Long safeguardId)
    {
        return frontInsureConfigSafeguardMapper.deleteFrontInsureConfigSafeguardBySafeguardId(safeguardId);
    }
}
